import "reflect-metadata";

const key = Symbol.for("descriptor");

export function descriptor(description: string) {
  return Reflect.metadata(key, description);
}

export function printObj(obj: any) {
  const cons = Object.getPrototypeOf(obj);
  // 类处理
  if (Reflect.hasMetadata(key, cons)) {
    console.log(Reflect.getMetadata(key, cons));
  } else {
    console.log(cons.constructor.name);
  }

  for (const k in obj) {
    if (Reflect.hasMetadata(key, obj, k)) {
      console.log(`\t${Reflect.getMetadata(key, obj, k)}: ${k}`);
    } else {
      console.log(`\t${k}: ${obj[key]}`);
    }
  }
}
